export default {
  // 所有子节点都挂载完成后调用
  async mounted(el: any, binding: any) {
    console.log("el节点的数据", el);
    console.log("图片节点的数据", binding);
    const imgComplete = await loadImg(binding.value);
    console.log("图片正在加载", imgComplete);
    if (imgComplete) {
      console.log("我已经图片加载完成了");
      el.setAttribute("src", "jsjsjsjsjssjsj");
    }
  },
};
function loadImg(url: string) {
  // 首先创建一个图片，
  return new Promise((resolve) => {
    const img = new Image();
    img.onload = function () {
      resolve(true);
    };
    img.onerror = function () {
      resolve(false);
    };
    img.src = url;
  });
}
